package org.xxx.epms.gateway.config.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.xxx.epms.gateway.dto.InspectorDetailsDto;
import org.xxx.epms.gateway.feign.InspectorFeign;

public class InspectorDetailsService implements UserDetailsService {

    private static final Logger log = LoggerFactory.getLogger(AdminDetailsService.class);

    @Autowired
    private InspectorFeign inspectorFeign;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        InspectorDetailsDto inspectorDetailsDto = inspectorFeign.getInsDetails(Integer.valueOf(username));
        InspectorDetails inspectorDetails =  new InspectorDetails(
                inspectorDetailsDto.getInsId(),
               inspectorDetailsDto.getInsPassword());

        return inspectorDetails;
    }
}
